package com.hackerrank.challenges.sherlockandqueries;

import java.util.Scanner;

public class Solution {
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt(), M = in.nextInt();
		long[] A = new long[N];
		int[] B = new int[M], C = new int[M];
		for(int i = 0; i < N; i++)
			A[i] = in.nextLong();
		for(int i = 0; i < M; i++)
			B[i] = in.nextInt();
		for(int i = 0; i < M; i++)
			C[i] = in.nextInt();
		for(int i = 0; i < M; i++) {
		    for(int j = B[i] - 1; j < N; j += B[i]) {
	            A[j] = (A[j] * C[i]) % 1000000007;
		    }
		}
		for(int i = 0; i < N; i++)
			System.out.print(A[i] + " ");
		System.out.println();
	}
}
